package com.example.demo.biz.impl;

import com.example.demo.biz.PricePostcodeBiz;
import com.example.demo.domain.model.PricePostcode;
import com.example.demo.domain.vo.PricePostcodeVO;
import com.example.demo.mapper.PricePostcodeMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;


/**
 * -- 价格-邮编基础信息表业务实现
 *
 * @author  zhiwen huang
 * @date  2020-12-23 23:04:09
 */
@Service
@Slf4j
public class PricePostcodeBizImpl implements PricePostcodeBiz {

	@Autowired
    private PricePostcodeMapper pricePostcodeMapper;


    /**
    * 根据id 查询
    * @param id
    * @return
    */
    @Override
    public PricePostcode getById(Integer id){
        if(null == id){
            return null;
        }
        return pricePostcodeMapper.getById(id);
    }

    /**
    * 插入一条数据
    * @param model
    * @return
    */
    @Override
    public void insert(PricePostcode model){
        if(null == model){
            return;
        }
        pricePostcodeMapper.insert(model);
    }

    /**
    * 根据id 更新不为null的参数,建议根据具体值更新对应的值
    * @param createTime
    * @return
    */
    //@Override
    //public int updateSelectiveById(PricePostcode model){
    //     if(null == model){
    //          return 0 ;
    //     }
    //    return pricePostcodeMapper.updateSelectiveBy(model);
    //}


    /**
    * 根据id列表 查询
    * @param ids
    * @return
    */
    @Override
    public List<PricePostcode> listByIds(List<Integer> ids){
        if(null == ids || ids.isEmpty()){
            return Collections.EMPTY_LIST;
        }
        return pricePostcodeMapper.listByIds(ids);
    }

    @Override
    public List<PricePostcodeVO> selectByPriceLadderId(Integer targetPriceLadderId) {
        return pricePostcodeMapper.selectByPriceLadderId(targetPriceLadderId);
    }

    @Override
    public void batchInsert(List<PricePostcode> pricePostcodes) {
        pricePostcodeMapper.batchInsert(pricePostcodes);
    }

}
